<?php
declare (strict_types=1);

namespace app\index\controller;

use app\common\model\Assets;
use app\common\model\Account as AccountModel;
use app\common\tool\Result;
use think\facade\View;
use think\Response;

class Account extends Base
{
    public function index(): string
    {
        View::assign('assets', Assets::getFields(3));

        return View::fetch();
    }

    public function record($type): string
    {
        View::assign([
            'title' => Assets::getFields(3)[$type],
            'type'  => $type
        ]);

        return View::fetch();
    }

    public function getList($type): Response
    {
        return Result::fastReturn(AccountModel::getPageList(['type' => $type, 'uid' => $this->user->id],
            'id,fx,amount,front,after,intro,source,create_time',
            $this->getPage(), $this->getLimit(), false));
    }
}